* C:\Work\ClimChgWelfare\Models\Models_2013_12\SummaryStats.do
* Ryan Kellogg
* Created: Sun, 22 Mar 2015 
* Last Modified: 

/*
Calcs summary stats for table 1 and other parts of the text
*/

capture log close
set more off
clear
use C:\Users\kelloggr\Dropbox\ClimateChangeQOL\DataPuma\ClimateRegressionData_150327.dta


* Stats on negative future temperature bins
gen NegBinCount = 0
gen NegBinAmount = 0
forvalues i = 1/222 {
	gen FutureClim`i' = bin`i' + DeltaA2Ensemble30Year_bin`i'
	replace NegBinCount = NegBinCount + 1 if FutureClim`i'<-0.1
	replace NegBinAmount = NegBinAmount + DeltaA2Ensemble30Year_bin`i' if FutureClim`i'<-0.1
}
sum NegBinCount, detail
replace NegBinAmount = NegBinAmount / 365.25
sum NegBinAmount, detail

* Climate summary stats
gen FutureHDD = HDD_Pres + Delta_HDD_A2Ensemble_30Year
gen FutureCDD = CDD_Pres + Delta_CDD_A2Ensemble_30Year
egen PrecipAvg = rowmean(Precip1-Precip12)
egen DeltaA2PrecipAvg = rowmean(DeltaA2Ensemble30YearPrecipT1-DeltaA2Ensemble30YearPrecipT12)
gen FuturePrecip = PrecipAvg + DeltaA2PrecipAvg
egen RelHumAvg = rowmean(RelHum1-RelHum12)
drop DeltaA2Ensemble30YearTempAvg* DeltaA2Ensemble30YearDewPt*
egen DeltaA2RelHumAvg = rowmean(DeltaA2Ensemble30YearRelHum1-DeltaA2Ensemble30YearRelHum12)
gen FutureHumid = RelHumAvg + DeltaA2RelHumAvg
egen Sun4SAvg = rowmean(Sun4S1-Sun4S12)
egen DeltaA2CloudFracAvg = rowmean(DeltaA2Ensemble30YearCloudFrac1-DeltaA2Ensemble30YearCloudFrac12)
gen FutureSun = Sun4SAvg - DeltaA2CloudFracAvg

sum HDD_Pres CDD_Pres PrecipAvg RelHumAvg Sun4SAvg, detail
sum FutureHDD FutureCDD FuturePrecip FutureHumid FutureSun, detail

* Other summary stats
sum Area mean_sea mean_lake slope_pct, detail
gen Pct_HSEd = 1 - sch_hsdo
gen Pct_BSEd = sch_cdeg
gen Pct_GradEd = sch_post
sum PopDens_Weighted Pct_HSEd Pct_BSEd Pct_GradEd age min_hisp min_blac Population QOL, detail

* Other weather correlation
reg Sun4SAvg RelHumAvg PrecipAvg

* Correlation table
correlate HDD_Pres CDD_Pres mean_sea mean_lake slope_pct
correlate HDD_Pres CDD_Pres PopDens_Weighted Pct_HSEd Pct_BSEd Pct_GradEd age min_hisp min_blac
